# output.target

- **Type:**

```ts
type RsbuildTarget = 'web' | 'node' | 'web-worker';
```

- **Default:** `'web'`
- **Version:** `>= 1.0.0`

Setting the build target of Rsbuild.

Rsbuild supports multiple build targets for running in different environments. After setting the target type, the default configuration of Rsbuild will change accordingly.

## Default Target

By default, the target is set to 'web' and will build outputs for running in the browser.

Rsbuild will read the [Browserslist config](https://github.com/browserslist/browserslist) in the project to determine the range of browsers.

## Optional Targets

In addition to `'web'`, `target` can also be set to the following values:

- `'node'`: Build for Node.js environment, usually used in SSR or other scenarios.
- `'web-worker'`: Build for web worker environment.

For example, to build for the Node.js environment:

```ts
export default {
  output: {
    target: 'node',
  },
};
```

## Parallel Builds

You can use [environments](/config/environments) to build multiple targets in parallel.

For example, to build `web` outputs and `node` outputs at the same time:

```ts
export default {
  environments: {
    web: {
      output: {
        target: 'web',
      },
    },
    node: {
      output: {
        target: 'node',
      },
    },
  },
};
```

## Node Target

Refers to the build target running in the Node.js environment, usually used in scenarios such as SSR.

When `target` is set to `'node'`, Rsbuild will:

- No HTML files will be generated, and HTML-related logic will not be executed, since HTML is not required by the Node.js environment.
- CSS code will not be bundled or extracted, but the id information of CSS Modules will be included in the bundle.
- The default code split strategy will be disabled, but dynamic import can still work.
- Disable the HMR.
- Adjust the default value of Browserslist to `['node >= 16']`.

## Web Worker Target

Refers to the build target running in the [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) environment.

:::tip Web Worker
A web worker is a type of JavaScript program that runs in the background, independently of other scripts, without affecting the performance of the page. This makes it possible to run long-running scripts, such as ones that handle complex calculations or access remote resources, without blocking the user interface or other scripts. Web workers provide an easy way to run tasks in the background and improve the overall performance of web applications.
:::

When `target` is set to `'web-worker'`, Rsbuild will:

- No HTML files will be generated, and HTML-related logic will not be executed, since HTML is not required by the Web Worker environment.
- CSS code will not be bundled or extracted, but the id information of CSS Modules will be included in the bundle.
- The default code split strategy will be disabled, and **dynamic import can not work**, because the Web Worker only runs a single JavaScript file.
- Disable the HMR.
